#include<fstream>
#include<sstream>
#include<string>
#include<vector>
#include<iostream>
//#include"../MyTools/LogFilePostProcess.hpp"

using namespace std;

class MatrixCsvReader
{
private:
	std::vector<std::vector<int> > m_mat;
	
public:
	MatrixCsvReader(const char* path, const bool delFirstLine = false);

	int getElement(const int& r, const int& c);
};
MatrixCsvReader::MatrixCsvReader(const char* path, const bool delFirstLine)
{
    ifstream fp(path);
    string line;
    if (delFirstLine)getline(fp, line);
    while (getline(fp, line))
    {
        std::vector<int> data_line;
        string number;
        istringstream readstr(line);
        while (getline(readstr, number, ','))
        {
            data_line.push_back(atoi(number.c_str()));
        }
        m_mat.push_back(data_line);
        //cout << data_line.size();
    }
};

int MatrixCsvReader::getElement(const int& r, const int& c)
{
    return m_mat[r][c];
}

